import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;

public class AddressPanelInOrder extends FlowPanel {
    Dimension lblSize = new Dimension(90, 60);
    Dimension tfdSize = new Dimension(300, 60);
    Font font = new Font("Monospaced", Font.PLAIN, 24);
    private ArrayList<JComponent> components = new ArrayList<>();

    JLabel lblName = new JLabel("姓名：");

    JTextField tfdName = new JTextField();

    JLabel lblTime = new JLabel("时间：");

    JTextField tfdTime = new JTextField();

    JLabel lblAddress = new JLabel("地址");

    JTextField tfdAddress = new JTextField();

    {
        components.add(lblName);
        components.add(tfdName);
        components.add(lblTime);
        components.add(tfdTime);
        components.add(lblAddress);
        components.add(tfdAddress);

        for (JComponent component : components
        ) {
            component.setFont(font);
            if (components.indexOf(component) % 2 == 0) {
                component.setPreferredSize(lblSize);
            } else {
                component.setPreferredSize(tfdSize);
            }
            add(component);
        }
        addButton();
    }

    public AddressPanelInOrder(FlowLayout flowLayout){
        super(flowLayout);
    }

    public JTextField getTfdName(){
        return this.tfdName;
    }

    public JTextField getTfdTime() {
        return tfdTime;
    }

    public JTextField getTfdAddress() {
        return tfdAddress;
    }
}
